#include <iostream>
#include <ratio>
#include <typeinfo>
#include <type_traits>

using namespace std;

template <size_t N>
constexpr size_t AddN = std::ratio_add<std::ratio<N>, std::ratio<1>>::num;
template <size_t N>
constexpr size_t DecN = std::ratio_subtract<std::ratio<N>, std::ratio<1>>::num;

template<size_t X, size_t N>
constexpr size_t PowN = std::ratio_multiply<std::ratio<X>, std::ratio<PowN<X, DecN<N>>>>::num;

template<size_t X>
constexpr size_t PowN<X, 0> = 1;

template<size_t N> constexpr size_t Bin = 1;
template<> constexpr size_t Bin<0> = 0;

template<size_t...>constexpr size_t Bit = 0;
template<size_t First, size_t... Rest>
constexpr size_t Bit<First, Rest...> = std::ratio_add<std::ratio<std::ratio_multiply<std::ratio<Bin<First>>, std::ratio<PowN<2, sizeof...(Rest)>>>::num>, std::ratio<Bit<Rest...>>>::num;
template<size_t N>
constexpr size_t Bit<N> = Bin<N>;

template<size_t N>
constexpr size_t BitN = std::ratio_add<std::ratio<BitN<DecN<N>>>, std::ratio<PowN<2, DecN<N>>>>::num;
template<> constexpr size_t BitN<0> = 0;

int main()
{
	cout << Bit<0> << endl;
	cout << Bit<1> << endl;
	cout << Bit<1, 0> << endl;
	cout << Bit<1, 1> << endl;
	cout << Bit<1, 0, 0> << endl;
	cout << Bit<1, 0, 1> << endl;
	cout << Bit<1, 1, 0> << endl;
	cout << Bit<1, 1, 1> << endl;
	cout << Bit<1, 0, 0, 0> << endl;

	cout << BitN<0> << endl;
	cout << BitN<1> << endl;
	cout << BitN<2> << endl;
	cout << BitN<3> << endl;
	cout << BitN<4> << endl;
	cout << BitN<5> << endl;
	cout << BitN<6> << endl;
	cout << BitN<7> << endl;
	cout << BitN<8> << endl;
	cout << BitN<9> << endl;
	cout << BitN<10> << endl;

	return 0;
}